import {login,getInfo,getCollect,updateInfo,delCollect} from '../../api';

export function userAction(mobile:string,password:string){
    return async(dispatch:Function)=>{
        const result = await login(mobile,password);
        dispatch({
            type:"INIT_USER",
            payload:result.data
        })
    }
}

export function userInfo(){
    return async(dispatch:Function)=>{
        const result = await getInfo();
        dispatch({
            type:"INIT_INFO",
            payload:result.data
        })
    }
}
export function updateInfoAction(avatar:string){
    return async(dispatch:Function)=>{
        const result = await updateInfo(avatar);
        dispatch({
            type:"UPDATE_INFO",
            payload:result
        })
    }
}
export function userCollect(typeId:string){
    return async(dispatch:Function)=>{
        const result = await getCollect(typeId);
       
        dispatch({
            type:"INIT_COLLECT",
            payload:result.data
        })
    }
}
export function delCollectAction(typeId:string,valueId:string){
    return async(dispatch:Function)=>{
        const result = await delCollect(typeId,valueId);
        dispatch({
            type:"DEL_COLLECT",
            payload:result.data
        })
    }
}